package com.woorigil.social.domain.point;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.woorigil.social.domain.SqlMapDaoSupport;
import com.woorigil.social.domain.deal.ManageStatus;

@Repository
public class DealPointDao extends SqlMapDaoSupport<DealPoint, Integer> {
	public static final String NAMESPACE = "DealPoint";

	@Override
	public String getNamespace() {
		return NAMESPACE;
	}

	@SuppressWarnings("unchecked")
	public List<DealPoint> search(DealPointCondition condition) {
		return getSqlMapClientTemplate().queryForList(getStatementName(NAMESPACE, "search"), condition);
	}

	public int updateClickCount(int dealId, int clickCount) {
		Map<String, Object> parmas = new HashMap<String, Object>();
		parmas.put("dealId", dealId);
		parmas.put("clickCount", clickCount);
		return getSqlMapClientTemplate().update(getStatementName(NAMESPACE, "updateClickCount"), parmas);
	}

	public int updateStatus(ManageStatus manageStatus) {
		Map<String, Object> parmas = new HashMap<String, Object>();
		parmas.put("manageStatus", manageStatus);
		return getSqlMapClientTemplate().update(getStatementName(NAMESPACE, "updateStatus"), parmas);
	}

	public int deleteByManageStatus(ManageStatus manageStatus) {
		Map<String, Object> parmas = new HashMap<String, Object>();
		parmas.put("manageStatus", manageStatus);
		return getSqlMapClientTemplate().delete(getStatementName(NAMESPACE, "deleteByManageStatus"), parmas);
	}
}